import moment from "moment";

export function formatDate(date) {

    //按照 今天 昨天 前天 和日期形式格式化日期
    let targetMoment = moment(date);
    let nowMoment = moment();

    const daysDiff = moment(nowMoment).diff(targetMoment, 'days');

    switch (daysDiff) {
        case 0: {
            return "今天"
        }
        case 1: {
            return "昨天"
        }
        case 2: {
            return "前天"
        }
    }
    return date;
}